blob: 8d5169a54c65797fc8df2db75992a3524922c098 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
---
import { type CollectionEntry, getCollection } from "astro:content";
import Comments from "../../components/Comments.astro";
import Layout from "../../layouts/BaseLayout.astro";
import blogPostSchema from "../../utils/schemas/blogPostSchema";
import dayjs from "dayjs";
type Props = CollectionEntry<"blog">;
export async function getStaticPaths() {
const posts = await getCollection("blog", ({ data }) => {
return data.draft !== true;
});
return posts.map((post) => ({
params: { slug: post.slug },
props: post,
}));
}
const post = Astro.props;
const { Content, remarkPluginFrontmatter } = await post.render();
const title = post.data.title;
const description = post.data.description;
const author = post.data.author;
const lang = post.data.lang;
const formattedData = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY");
const data = post.data.pubDate.toISOString();
const schema = blogPostSchema({
siteUrl: new URL("/", Astro.site).toString(),
title,
slug: post.slug,
datePublished: data,
author,
});
---
<style lang="scss">
@use "../../scss/variables" as *;
p {
opacity: 0.5;
}
</style>
<Layout title={title} description={description} lang={lang} schema={schema}>
<article>
<section>
<h1>{title}</h1>
</section>
<section>
<p>
<small>
Posted
<time datetime={data} lang="en">{formattedData}</time>
by {author}
<span> • </span>
<span>{remarkPluginFrontmatter.minutesRead}</span>
</small>
</p>
</section>
<section>
<Content />
</section>
<section>
<Comments />
</section>
</article>
</Layout>
|